/*
*  Copyright 2019-2023 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.biz.rest;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.annotation.Log;
import me.zhengjie.exception.BizException;
import me.zhengjie.modules.biz.domain.resp.WxUserVolunteerResp;
import me.zhengjie.modules.biz.service.VolunteerFormService;
import me.zhengjie.modules.biz.domain.vo.VolunteerFormQueryCriteria;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;

/**
* @author yiwei.he
* @date 2024-03-14
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "我的志愿表管理")
@Slf4j
@RequestMapping("/api/volunteerForm")
public class VolunteerFormController {

    private final VolunteerFormService volunteerFormService;

    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    public void exportVolunteerForm(HttpServletResponse response, VolunteerFormQueryCriteria criteria) throws IOException, BizException {
        log.info("/api/volunteerForm/download  导出志愿表数据：{}",criteria);
        volunteerFormService.download(volunteerFormService.queryAll(criteria), response);
    }

    @GetMapping
    @Log("查询志愿表集合")
    @ApiOperation("查询志愿表集合")
    public ResponseEntity<PageResult<WxUserVolunteerResp>> queryVolunteerForm(VolunteerFormQueryCriteria criteria, Page<Object> page) throws BizException {
        log.info("/api/volunteerForm  查询志愿表集合：{}",criteria);
        return new ResponseEntity<>(volunteerFormService.queryAll(criteria,page),HttpStatus.OK);
    }

}